# coding=utf-8
# -*- coding: UTF-8 -*-
#
# This file is part of the kernelstudio package.
#
# (c) 2014-2025 zlin <admin@kernelstudio.com>
#
# For the full copyright and license information, please view the LICENSE file
# that was distributed with this source code.

from pydantic import Field
from pydantic_settings import BaseSettings

driver_mapping = {
    "postgresql": "postgresql+psycopg2",
    "mysql": "mysql+pymysql",
    "oracle": "oracle+oracledb",
    "mssql": "mssql+pymssql",
}


class DatabaseConfig(BaseSettings):
    """
    Settings for database type
    """
    DATABASE_TYPE: str = Field(
        description="Type of database.",
        default="postgresql",
        envvar='DATABASE_TYPE'
    )

    DATABASE_HOST: str = Field(
        description="Database host.",
        default="localhost",
        envvar='DATABASE_HOST'
    )

    DATABASE_PORT: int = Field(
        description="Database port.",
        default="3306",
        envvar='DATABASE_PORT'
    )

    DATABASE_USERNAME: str = Field(
        description="Database username.",
        default="root",
        envvar='DATABASE_USERNAME'
    )

    DATABASE_PASSWORD: str = Field(
        description="Database password.",
        default="admin",
        envvar='DATABASE_PASSWORD'
    )

    DATABASE_NAME: str = Field(
        description="Database name.",
        default="ksai",
        envvar='DATABASE_NAME'
    )

    DATABASE_PROPERTIES: str = Field(
        description="Database properties.",
        default="",
        envvar='DATABASE_PROPERTIES'
    )

    DATABASE_CHANGELOG_TABLE: str = Field(
        description="Database changelog table name.",
        default="ksai_database_changelog",
        envvar='DATABASE_CHANGELOG_TABLE'
    )


database_config = DatabaseConfig()
